package com.jing.android.notes.ui.home;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.AsyncDifferConfig;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.button.MaterialButton;
import com.jing.android.notes.R;
import com.jing.android.notes.template.TemplateScrollingActivity;
import com.jing.android.notes.ui.thread.ThreadActivity;
import com.jing.android.notes.ui.widget.TextAdapter;
import com.jing.android.notes.ui.widget.ArrowDrawable;

public class HomeFragment extends Fragment implements View.OnClickListener {

    private HomeViewModel homeViewModel;

    private RecyclerView recyclerView;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        homeViewModel =
                new ViewModelProvider(this).get(HomeViewModel.class);
        View root = inflater.inflate(R.layout.fragment_home, container, false);
        MaterialButton btnThread = root.findViewById(R.id.btn_thread);
        btnThread.setOnClickListener(this);
        root.findViewById(R.id.btn_template_scrolling).setOnClickListener(this);
        recyclerView = root.findViewById(R.id.recycle_view);
        recyclerView.setAdapter(new TextAdapter(recyclerView.getContext()));
        return root;
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn_thread) {
            startActivity(new Intent(v.getContext(), ThreadActivity.class));
        }
        if (v.getId() == R.id.btn_template_scrolling) {
            startActivity(new Intent(v.getContext(), TemplateScrollingActivity.class));
        }
    }
}